From: Thomas Leonard Date: Wed, 16 Jul 2014 11:07:41 +0000 (+0100) Subject: mini-os: x86_64: make thread stacks 16-byte aligned X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~4644 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=750cdc32d73f8d5e4e1cbd1f252dd145e8e8c962;p=xen.git mini-os: x86_64: make thread stacks 16-byte aligned Otherwise, passing doubles to varargs functions causes a crash. Signed-off-by: Thomas Leonard Acked-by: Samuel Thibault --- diff --git a/extras/mini-os/arch/x86/sched.c b/extras/mini-os/arch/x86/sched.c index 8a05b58dcb..e4a3dc2917 100644 --- a/extras/mini-os/arch/x86/sched.c +++ b/extras/mini-os/arch/x86/sched.c @@ -107,6 +107,9 @@ struct thread* arch_create_thread(char *name, void (*function)(void *), thread->sp = (unsigned long)thread->stack + STACK_SIZE; /* Save pointer to the thread on the stack, used by current macro */ *((unsigned long *)thread->stack) = (unsigned long)thread; + + /* Must ensure that (%rsp + 8) is 16-byte aligned at the start of thread_starter. */ + thread->sp -= sizeof(unsigned long); stack_push(thread, (unsigned long) function); stack_push(thread, (unsigned long) data);